package com.xyw.code.controller;


import com.xyw.code.log.SysLog;
import com.xyw.code.service.ISysLogService;
import com.xyw.code.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author xuyiwei
 * @since 2019-07-30
 */
@RestController
@RequestMapping("/log")
public class SysLogController {

    @Autowired
    private ISysLogService logService;

    /**
     * 日志集合
     * @param page
     * @return
     */
    @GetMapping("/list")
    @PreAuthorize("hasAuthority('sys:log:view')")
    public Result getList(Integer page, Integer pageSize,Integer type,String userName,String description) {
        return Result.ok(logService.getLogList(page, pageSize,type,userName,description));
    }

    /**
     * 删除日志
     * @param ids
     * @return
     */
    @SysLog(descrption = "删除日志")
    @PostMapping("/delete")
    @PreAuthorize("hasAuthority('sys:log:delete')")
    public Result delete(@RequestBody  List<Integer> ids) {
        return Result.ok(logService.deleteByIds(ids));
    }
}

